//
//  MTBaseViewController.m
//  MeToo
//
//  Created by 俊松何 on 2018/7/3.
//  Copyright © 2018年 tianxie. All rights reserved.
//

#import "MTBaseViewController.h"

@interface MTBaseViewController ()

@end

@implementation MTBaseViewController
+(id)baseStoryBordWithName:(NSString *)storyboardName
{
    
    UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    UIViewController *Vc = [storyBoard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%@ID",NSStringFromClass(self)]];
    return Vc;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    if(_backImage == nil)
    {
        _backImage = @"back_black"; 
    }
    [self.navigationController.navigationBar lt_setBackgroundColor:navgationBarColor];
    self.navigationController.navigationBar.backgroundColor = navgationBarColor;
    // 添加返回按钮
    if(self.navigationController.childViewControllers.count > 0 && self != self.navigationController.viewControllers[0]) {
        UIButton *but = [UIButton buttonWithType:UIButtonTypeCustom];
        [but setImage:[UIImage imageNamed:_backImage] forState:UIControlStateNormal];
        [but setImage:[UIImage imageNamed:_backImage] forState:UIControlStateHighlighted];
        [but addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
        but.frame = CGRectMake(0, 0, 40, 40);
        but.contentMode = UIViewContentModeLeft;
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:but];
        self.navigationItem.leftMargin = 0;
    }
    self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}


#pragma mark - 返回界面方法
-(void)goBack
{
    
    [self.navigationController popViewControllerAnimated:!_noBackAnimation];
}


@end
